package com.novel.controller.system;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.alipay.api.response.AlipayTradePagePayResponse;
import com.novel.common.event.UserRecommendEvent;
import com.novel.common.event.UserRecommendPojo;
import com.novel.common.exception.CustomerException;
import com.novel.common.vo.AliPayVo;
import com.novel.config.AliPayConfig;
import com.novel.controller.other.BaseController;
import com.novel.pojo.system.Order;
import com.novel.service.AliPayService;
import com.novel.service.OrderService;
import com.novel.utils.GsonTool;
import com.novel.utils.OrderNoUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


import java.util.Date;
import java.util.UUID;

@Slf4j
@Controller
@RequestMapping("alipay")
public class AliPayController extends BaseController {

    @Autowired
    private AliPayService aliPayService;

    /**
     * 提交充值请求
     * 1.创建订单
     * 2.跳转到支付页面
     */
    @PostMapping("jump")
    @ResponseBody
    public String jumpPayPage(String id) throws AlipayApiException {
        return aliPayService.pay(getUserInformation(), getUserIpAddress(), id);
    }

}